<!--
 * @Author: lixb
 * @Date: 2020-08-19 10:29:30
 * @LastEditTime: 2020-09-24 15:12:42
 * @Descripttion: 生日墙模块
-->
<template>
  <div v-show="birthdayPartList.length > 1">
    <el-card class="box-card">
      <div slot="header" class="clearfix" @click="goBirthdayParty">
        <span class="modul-title">
          <img src="@/assets/img/生日墙.png" style="height: 25px;width: 25px;margin-right: 10px;" />
          <span>生日墙</span>
        </span>
        <span class="title-right" type="text">
          本月有
          <span style="color: #3771E9">{{ birthdayPartList.length }}</span>
          人过生日
        </span>
      </div>
      <div class="text item card-main">
        <el-scrollbar class="">
          <div v-for="item in birthdayPartList" :key="item.userId" class="birthday-main">
            <img class="head-img" :src="item.avatar" />
            <p class="birthday-name" :title="item.realName">{{ item.realName }}</p>
            <p class="birthday-date">{{ item.birthday.substring(5, 10) }}</p>
          </div>
        </el-scrollbar>
      </div>
    </el-card>
  </div>
</template>

<script>
  import { getBirthdayWall } from '@/api/home';
  import { hasMenu } from '@/plugins/hasMenu';
  export default {
    data() {
      return {
        birthdayPartList: [],
      };
    },
    activated() {
      this.getUserList();
    },
    methods: {
      getUserList() {
        let params = {
          month: new Date().getMonth() + 1,
        };
        getBirthdayWall(params).then(res => {
          if (res.status == 200) {
            this.birthdayPartList = res.data || [];
          }
        });
      },
      goBirthdayParty() {
        if (hasMenu('WALFARE-RCFL-SRH')) {
          this.$router.push('/birthdayParty/index');
        } else {
          this.$message.error('暂无操作权限！');
        }
      },
    },
  };
</script>

<style lang="scss" scoped>
  .el-card.is-always-shadow {
    border-radius: 10px;
  }

  .box-card {
    margin-top: 10px;
    .clearfix {
      cursor: pointer;
    }
    .title-right {
      float: right;
      padding: 3px 0;
      font-size: 12px;
      color: #868686;
    }
    .modul-title * {
      font-weight: bold;
      font-size: 18px;
      display: inline-block;
      vertical-align: middle;
    }
    .card-main {
      width: 100%;
      white-space: nowrap;
      overflow-y: hidden;
      height: 130px;
    }
    .birthday-main {
      display: inline-block;
      width: 85px;
      text-align: center;
      .birthday-name {
        width: 80px;
        overflow: hidden;
      }
      .head-img {
        margin: auto;
        width: 35px;
        height: 35px;
      }
      .birthday-date {
        font-size: 12px;
        color: #666666;
      }
    }
  }
</style>
